﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CheckSort
{
    class Utils
    {
        public static uint EnterUint()
        {
            uint result = 0;
            bool correctFlag = false;
            int maxValue = 6000;
            do
            {
                while (!uint.TryParse(Console.ReadLine(), out result))
                    Console.WriteLine(Literals.TRYAGAIN);
                if (result > maxValue)
                {
                    Console.WriteLine(Literals.TRYAGAIN);
                    correctFlag = false;
                }
                else if (result < 0)
                {
                    Console.WriteLine(Literals.TRYAGAIN);
                    correctFlag = false;
                }
                else correctFlag = true;
            } while (!correctFlag);
            return result;
        }
        public static uint EnterUint(long maxValue)
        {
            uint result = 0;
            bool correctFlag = false;
            do
            {
                while (!uint.TryParse(Console.ReadLine(), out result))
                    Console.WriteLine(Literals.TRYAGAIN);
                if (result > maxValue)
                {
                    Console.WriteLine(Literals.TRYAGAIN);
                    correctFlag = false;
                }
                else if (result < 0)
                {
                    Console.WriteLine(Literals.TRYAGAIN);
                    correctFlag = false;
                }
                else correctFlag = true;
            } while (!correctFlag);
            return result;
        }
    }
}
